/*
 * libjingle
 * Copyright 2004--2005, Google Inc.
 */

#ifndef _XMPPAUTH_H_
#define _XMPPAUTH_H_

#include <vector>

#include "base/cryptstring.h"
#include "base/sigslot.h"
#include "xmpp/jid.h"
#include "xmpp/saslhandler.h"
#include "xmpp/prexmppauth.h"

class XmppAuth: public buzz::PreXmppAuth {
public:
  XmppAuth();
  virtual ~XmppAuth();
  
  virtual void StartPreXmppAuth(const buzz::Jid & jid,
                                const talk_base::SocketAddress & server,
                                const talk_base::CryptString & pass,
                                const std::string & auth_cookie);
 
  virtual bool IsAuthDone() { return done_; }
  virtual bool IsAuthorized() { return !error_; }
  virtual bool HadError() { return error_; }
  virtual int  GetError() { return 0; }
  virtual buzz::CaptchaChallenge GetCaptchaChallenge() {
      return buzz::CaptchaChallenge();
  }
  virtual std::string GetAuthCookie() { return auth_cookie_; }

  virtual std::string ChooseBestSaslMechanism(
      const std::vector<std::string> & mechanisms,
      bool encrypted);

  virtual buzz::SaslMechanism * CreateSaslMechanism(
      const std::string & mechanism);

private:
  buzz::Jid jid_;
  talk_base::CryptString passwd_;
  std::string auth_cookie_;
  bool done_, error_;
};

#endif
